package com.zulin.quartz;

import java.util.Date;

import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.impl.StdSchedulerFactory;

public class Sched {
	
	private Date reminddate;
	private String title;
	private String content;
	private String targetdate;
	private String createdate;
	
	
	

	public void startShedule() throws SchedulerException{  
		
		content = "您在"+createdate+"设立一个提醒,在"+targetdate+"内容为"+content;
		System.out.println(title);
		System.out.println(content);
		
	     /*调度器*/  
	    Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();  
	    /*具体执行类*/  
	    JobDetail job = JobBuilder.newJob(Jobs.class)
	    	    .withIdentity("job1", "group1")
	    	    .usingJobData("jobSays", "Hello World!")
	    	    .usingJobData("title", title)
	    	    .usingJobData("content", content)
	    	    
	    	    .build();
	    System.err.println(reminddate);
	    Trigger trigger = TriggerBuilder.newTrigger()
	    		.withIdentity("trigger1", "group1")
	    	    .startAt(reminddate) 
	    	    .forJob("job1", "group1") 
	    	    .build();
	    
	    
	    scheduler.scheduleJob(job, trigger);  
	    scheduler.start();  
	  
	}
	
	

	public Date getReminddate() {
		return reminddate;
	}

	public void setReminddate(Date reminddate) {
		this.reminddate = reminddate;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getTargetdate() {
		return targetdate;
	}

	public void setTargetdate(String targetdate) {
		this.targetdate = targetdate;
	}

	public String getCreatedate() {
		return createdate;
	}

	public void setCreatedate(String createdate) {
		this.createdate = createdate;
	}
	 
	 
}
